<?php
$GLOBALS['Md'] = "Support";
$GLOBALS['Pd'] = "N";
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.php");
print heade(); 
print body(); 
module($BSD['DB00']);
office_header($_SESSION['office']);
include($GLOBALS['PAD']."Modules/Support/main.obj.php");
include($GLOBALS['PAD']."Modules/Support/nav.views.php");
print NavFront();
// SAVE TICKET
if (isset($_POST['SaveTicket'])) {
	if ($_POST['Area'] != "") {
	$timeCreation = date("Y-m-d H:i:s");
	if ($_POST['date_occur'] != "AAAAMMDD") {
	$timeOccur = $_POST['date_occur']." ".$_POST['time_occur'].":00";
	} else {
	$timeOccur = $timeCreation;
	}
	
	$QAttrib = "SELECT * FROM administration_it WHERE refArea = '{$_POST['Area']}'";
	$Attrib = $GLOBALS['CONN']->db_array($QAttrib);
		
	$CSave = "INSERT INTO it_tickets (main_users_ref, main_domain_ref, main_office_ref, Description, ref_type, time_creation, priority, status, time_occur, refUserAtrib) 
	VALUES ('{$_SESSION['UtID']}','1','{$_SESSION['office']}','{$_POST['Description']}','{$_POST['Area']}','{$timeCreation}','1','1','{$timeOccur}','{$Attrib[1]['refUserAtrib']}')";
	$Save = $GLOBALS['CONN']->db_query($CSave);
	$Msg->SAVE_CLIENT = "Ticket Enviado.";
	} else {
	$Msg->SAVE_CLIENT = "Preencha todos os campos.";
	}
} 
?>
<table width="100%"  border="0" cellpadding="10">
  <?php 
	if (isset($_GET['action']) && $_GET['action'] == "requests") {
		include($GLOBALS['PAD']."Modules/Support/Front/requests/viewrequests.php");
	} elseif (isset($_GET['action']) && $_GET['action'] == "show" || !isset($_GET['action'])) {
		include($GLOBALS['PAD']."Modules/Support/Front/itactivities/viewtickets.php");
	} elseif (isset($_GET['action']) && $_GET['action'] == "new") {
		include($GLOBALS['PAD']."Modules/Support/Front/itactivities/addtickets.php");
	} elseif (isset($_GET['action']) && $_GET['action'] == "done") {
		include($GLOBALS['PAD']."Modules/Support/Front/itactivities/ticketmsg.php");
	} elseif (isset($_GET['action']) && $_GET['action'] == "petty") {
		include($GLOBALS['PAD']."Modules/Support/Front/requests/addpetty.php");
	} elseif (isset($_GET['action']) && $_GET['action'] == "loc") {
		include($GLOBALS['PAD']."Modules/Support/Front/act001mng/add.php");
	} else {
		include($GLOBALS['PAD']."Modules/Support/Front/requests/edrequest.php");
	} ?>
</table>
<?php print footer(); ?>